/***************************************************************
 *  Copyright (c) 2007 by GroupMe! Team (www.groupme.net)
 *  All rights reserved.
 *
 *  This file is part of the GroupMe! Project. Source code of 
 *  this project is closed and redistribution of this code is
 *  prohibited. 
 *  
 *  Contact: http://www.groupme.net
 *
 *  This copyright notice MUST APPEAR in all copies of the file!
 ***************************************************************/
package net.groupme.model.dao.mem;

import java.net.URI;
import java.net.URISyntaxException;

import net.groupme.gui.rendering.RenderingUtility;
import net.groupme.gui.rendering.constants.RENDERING_CONSTANTS;
import net.groupme.model.GroupVisualization;
import net.groupme.model.Resource;
import net.groupme.model.dao.ResourceVisualizationDAO;

/**
 * created on 21.02.2008
 * 
 * This class is a Memory persitent implemenation of a resource Visualisation
 * 
 * @author Patrick Siehndel <a href="mailto:patrick.siehndel@gmx.de">patrick.siehndel@gmx.de</a>$
 * 
 * @version $Revision: 1.4 $ $Date: 2008-06-17 11:42:21 $
 */
public class ResourceVisualizationDAOMemImpl implements
		ResourceVisualizationDAO {

	private String label = null;
	private String description = null;
	private String id = null;
	private int height = 0;
	private int positionX = 0;
	private int positionY = 0;
	private String renderer = RENDERING_CONSTANTS.RENDERER_DEFAULT;
	private Resource resource = null;
	private int width = 0;
	private int ZAxis = 100;
	private GroupVisualization groupVisualization = null;

	public ResourceVisualizationDAOMemImpl(int width, int height, int posX, int posY, String id){
		this.width = width;
		this.height = height;
		this.positionX = posX;
		this.positionY = posY;
		this.id = id;
	}
	
	public ResourceVisualizationDAOMemImpl(GroupVisualization gVisu, Resource resource){
		this.resource = resource;
		this.renderer = RenderingUtility.suggestRenderer(resource.getType());
		this.groupVisualization = gVisu;
		this.label = "Visualization of " + resource.getLabel();
		this.id = resource.getId();
	}
	
	public GroupVisualization getGroupVisualization() {
		return this.groupVisualization;
	}

	public int getHeight() {
		return height;
	}

	public int getPositionX() {
		return positionX;
	}

	public int getPositionY() {
		return positionY;
	}

	public String getRenderer() {
		return renderer;
	}

	public Resource getResource() {
		return resource;
	}

	public int getWidth() {
		return width;
	}

	public int getZAxis() {
		return ZAxis;
	}

	public void setGroupVisualization(GroupVisualization visualization) {
		this.groupVisualization = visualization;
	}

	public void setHeight(int height)  {
		this.height = height;
	}

	public void setPositionX(int posX)  {
		this.positionX = posX;
	}

	public void setPositionY(int posY) {
		this.positionY = posY;

	}

	public void setRenderer(String renderer) {
		this.renderer = renderer;
	}

	public void setResource(Resource resource) {
		this.resource = resource;

	}

	public void setWidth(int width)  {
		this.width = width;

	}

	public void setZAxis(int axis)  {
		this.ZAxis = axis;

	}

	public String getDescription() {
		return this.description;
	}

	public String getId() {
		return this.id;
	}

	public String getLabel() {
		return label;
	}

	public URI getURI(){
		try {
			return new URI("http://www.groupme.net/resourcevisualization/" + this.id);//$NON-NLS-1$
		} catch (URISyntaxException e) {
			e.printStackTrace();
			return null;
		} 
	}

	public void setDescription(String description)  {
		this.description = description;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return this.getLabel() + ": height: " + this.height + ", width: " + this.width + ", (x, y, z) = (" + this.positionX + ", " + this.positionY + ", " + this.ZAxis + ")" ;
	}

}
